import { spotMarket } from "@src/api/spotMarket"
import { DataSourceTypeByDateEnum, dataSourceKeyInfo } from "@src/globalData/enum";

import { dataCategory } from "@src/dataFormatConversion/constant"

const dTypes:Record<string, string> = {
  [DataSourceTypeByDateEnum.D_ADD_DATE]: 'D+1',
  [DataSourceTypeByDateEnum.D_DATE]: 'D',
  [DataSourceTypeByDateEnum.D_REDUCE_DATE]: 'D-1',
}

export const getAllSingleDataList = () => {
  const dataList:{value:string,label:string,label1:string,label2:string,label3:string}[] = []
  for(let key in dataCategory) {
    dataCategory[key as keyof typeof dataCategory].forEach(value => {
      if(!Object.keys(spotMarket).includes(value)) return
      
      dataList.push({
        value,
        label: `${dTypes[key as any]} ${value} ${dataSourceKeyInfo?.[value].dataItemName}`,
        label1: dTypes[key as any],
        label2: value,
        label3: dataSourceKeyInfo?.[value].dataItemName
      })
    })
  }

  return dataList
}
